import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ConfigTypeVO, ConfigTypeForm, ConfigTypeQuery } from '@/api/business/configType/types';

/**
 * 查询业务参数配置类型列表
 * @param query
 * @returns {*}
 */

export const listConfigType = (query?: ConfigTypeQuery): AxiosPromise<ConfigTypeVO[]> => {
  return request({
    url: '/business/configType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询业务参数配置类型详细
 * @param configTypeId
 */
export const getConfigType = (configTypeId: string | number): AxiosPromise<ConfigTypeVO> => {
  return request({
    url: '/business/configType/' + configTypeId,
    method: 'get'
  });
};

/**
 * 新增业务参数配置类型
 * @param data
 */
export const addConfigType = (data: ConfigTypeForm) => {
  return request({
    url: '/business/configType',
    method: 'post',
    data: data
  });
};

/**
 * 修改业务参数配置类型
 * @param data
 */
export const updateConfigType = (data: ConfigTypeForm) => {
  return request({
    url: '/business/configType',
    method: 'put',
    data: data
  });
};

/**
 * 删除业务参数配置类型
 * @param configTypeId
 */
export const delConfigType = (configTypeId: string | number | Array<string | number>) => {
  return request({
    url: '/business/configType/' + configTypeId,
    method: 'delete'
  });
};

/**
 * 同步超级管理员的业务参数配置到当前租户
 */
export const syncConfig = () => {
  return request({
    url: '/business/configType/syncConfig',
    method: 'put'
  });
};
